#include "EGame.h"
#include "ECharacter.h"
#include "eCPP.h"

namespace engine
{

EGame* g_pGame = NULL;

//------------------------------------------------------------
EGame::EGame() : 
m_pPlayerCharacter( NULL ),
m_bGameStarted( false )
{

}

//------------------------------------------------------------
EGame::~EGame()
{
  if( m_bGameStarted )
    cTEST_NO_RETURN( endGame() );
}

//------------------------------------------------------------
bool EGame::update( float fTimeSinceLastFrame )
{
  m_gameTime.setTimeSinceLastFrame( fTimeSinceLastFrame );
  cTEST( m_sceneManager.update( m_gameTime ) );
  if( m_bGameStarted )
    cTEST( m_sceneManager.updateGame( m_gameTime ) );
  
  return true;
}

//------------------------------------------------------------
bool EGame::startGame()
{
  cASSERT( !m_bGameStarted );

  cTEST( m_sceneManager.startGame() );
  m_bGameStarted = true;

  return true;
}

//------------------------------------------------------------
bool EGame::endGame()
{
  cASSERT( m_bGameStarted );

  cTEST( m_sceneManager.endGame() );
  m_bGameStarted = false;

  return true;
}

//------------------------------------------------------------
EScene*   EGame::createScene(const string& sName, const ESceneDesc& sceneDesc)
{
  EScene* pScene = NULL;

  pScene = m_sceneManager.createScene( sName, sceneDesc );
  return pScene;
}

//------------------------------------------------------------
bool    EGame::setCurrentScene(const string& sName )
{
  return m_sceneManager.setCurrentScene( sName );
}

} // end namespace